import 'package:flutter/material.dart';
import 'custom_painter.dart';

class StopAnime extends StatefulWidget {
  const StopAnime({super.key});

  @override
  State<StopAnime> createState() => _StopAnimeState();
}

class _StopAnimeState extends State<StopAnime>
    with TickerProviderStateMixin {
  late Animation<double> animation;

  @override
  void initState() {
    super.initState();
    //动画设置
    var controller = AnimationController(
        duration: const Duration(milliseconds: 10000), vsync: this);

    animation = Tween(begin: 0.0, end: 1.0).animate(controller)
      ..addListener(() {
        setState(() {});
      });
    controller.forward();
  }
  @override
  Widget build(BuildContext context) {
    // debugPrint("initState animation ${animation.value}");
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Colors.orange,
        title: const Text("禁止动画"),
      ),
      body:
      Center(
        child: CustomPaint(
          size: const Size(100, 100),
          // painter:  MyCustomPainter(),
          painter: MyCustomPainter(animation.value),
        ),
      ),
    );
  }
}
